﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SharedLib.BasicServices.MessageFramework
{
    public abstract class AppMessageGeneric<TData, TResult> : IAppMessage where TResult:class
    {
        TData _data;
        TResult _result;
        MessageCallback _callback;
        Exception _exception;
        object _sender;

        public abstract Type Handler
        {
            get;
        }

        public object Data
        {
            get { return GenericData; }
        }

        public TData GenericData
        {
            get { return _data; }
        }

        public TResult GenericResult
        {
            get { return _result;  }
            set { _result = value; }
        }

        public object Result
        {
            get { return GenericResult; }
            set { GenericResult = value as TResult; }

        }
        public MessageCallback CallBack
        {
            get { return _callback; }
        }

        public Exception Exception
        {
            get { return _exception; }
            set { _exception = value; }
        }

        public object Sender
        {
            get { return _sender; }
        }

        public AppMessageGeneric(object sender, TData data, MessageCallback callback)
        {
            _sender = sender;
            _data = data;
            _callback = callback;
        }
    }
}
